% Parameters for intensity channel 

%% input parameters
% fpath = 'balloons.png'; %'pout.tif';
inputvideo = 'V3V100013_010.crop.avi'; %'video.avi';
color_img = 1;  % flag to enable pre-processing if color-image

%% algorithmic parameters
nr = 256; %128;       %input image size - num of rows
nc = 256; %128;       %input image size - num of cols



bin_dat_bar = 0; %1;     %0 : dat file (ascii), 1 : binary file

fpath = '../Data/onboard/'; %'../Data/bin/';

%% for comparing hardware result
%% pre-processing

  %  im1 = imread(fpath);
   % im2 = imresize(im1, [nr, nc]);
 
    mov = aviread(inputvideo) ; 
    NUM_FRAMES = 2; %size(mov,2);
    
    I_prev = zeros(nr,nc);
   for i = 1:NUM_FRAMES %will go to number of frames
 
    datfileframe = strcat(fpath, int2str(i),'-');
    im2= mov(1,i).cdata;
    im2 = imresize(im2, [nr,nc]);   % resize to desired img size

    datfile = strcat(datfileframe, 'in', '.dat');
    rgb2dat_n(datfile, double(im2), 2); % 2 pixels per line of the file => 64-bit data
                 
%     img = double(im2)./255 ;
%     [I R G B Y] = SalColorMap(img);   % Generate I, RG and BY channels 
%     
% %     img = I; %abs(R - G);   
%     RG = R - G; %img3 = R-G;
%     BY = B - Y; %img4 = B-Y; 
%     F = abs(I - I_prev);
%     
%         %-----------------Int
%     
%         
%         if(bin_dat_bar == 1)     %0 : dat, 1 : bin
%             % For on-board test
%             binfile_I = strcat(datfileframe,'0','.bin');
%             binfile_RG = strcat(datfileframe,'2','.bin');        
%             binfile_BY = strcat(datfileframe,'3','.bin');     
% %             binfile_F = strcat(datfileframe,'1','.bin'); 
%             
%             q = quantizer('fixed', [32,20]);    %input data representation (32 bits, 20 fraction bits)
%             
%             array2bin(binfile_I, I, nr, nc, q);
%             array2bin(binfile_RG, RG, nr, nc, q);
%             array2bin(binfile_BY, BY, nr, nc, q);       
% %             array2bin(binfile_F, F, nr, nc, q);       
%         else
%             % For Simulation
%             datfile_I = strcat(datfileframe,'0','.dat');
%             datfile_RG = strcat(datfileframe,'2','.dat');        
%             datfile_BY = strcat(datfileframe,'3','.dat');   
%             datfile_F = strcat(datfileframe,'1','.dat');
%  
%             
%             q = quantizer('fixed', [24,20]);    %input data representation (24 bits, 20 fraction bits)
%             
% %             array2dat(datfile_I, I, nr,nc, q);    
% %             array2dat(datfile_RG, RG, nr,nc, q);    
% %             array2dat(datfile_BY, BY, nr,nc, q);
% 
%                        
%             array2dat64(datfile_I, I, nr,nc);    
%             array2dat64(datfile_RG, RG, nr,nc);    
%             array2dat64(datfile_BY, BY, nr,nc);
% 
% %             if(i > 1)
% %                 array2dat(datfile_F, F, nr,nc, q);
% %             end
%         end
%         
%         I_prev = I;
   end 
